home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
border80.zip
/
BORDER80.PAS
Wrap
Pascal/Delphi Source File
|
1985-11-12
|
4KB
|
121 lines
{DEMO OF TURBO PASCAL 2.0 80 COLUMN SCREEN BORDER COLOR CONTROL}
{$C-}
program border_color_test;
type ColorArray = array[0..15] of string[13];
const color:ColorArray = ('Black','Blue','Green','Cyan','Red','Magenta',
'Brown','White','Gray','Light Blue','Light Green',
'Light Cyan','Light Red','Light Magenta','Yellow',
'Light White');
var
i,wait,offset:integer;
tempoffset:real;
ch:char;
colormessage:string[18];
num:string[3];
procedure GetInteger(var number:integer); {Protect against bad input}
type characters = set of char;
var buffer:string[4];ch:char;x,y,result:integer;numerals:characters;
begin
x:=wherex;y:=wherey;
numerals := ['0'..'9'];
buffer:='';
repeat
if keypressed then
begin
read(kbd,ch);
if ch in numerals then
begin
buffer:=buffer+ch;
write(ch);
end;
if ch=#27 then halt;
if ch=#8 then
begin
delete(buffer,length(buffer),1);
gotoxy(x,y);write(buffer,' ');gotoxy(wherex-1,y);
end;
end;
until (ch=#13) or (length(buffer)=4);
val(buffer,number,result);
if result <>0 then write('ERROR IN OBTAINING INTEGER!!');
if number>1000 then
begin
textcolor(14);
gotoxy(x,y);write(' ** 1000 maximum **');
textcolor(6);
gotoxy(x,y);GetInteger(number);
gotoxy(x+5,y);write(' ');
end;
gotoxy(x,y);textcolor(11);write(number,' ');textcolor(6);
end;
procedure CursorOff;
begin
port[$3d4]:=10; { 6845 crt controller ind reg;points to reg to rec }
port[$3d5]:=9; { data which is output to reg here;strt scan ln=9 }
port[$3d4]:=11; { index to reg for cursor stop scan ln }
port[$3d5]:=8; { stop scan line=8 }
end;
procedure CursorOn;
begin
port[$3d4]:=10;
port[$3d5]:=6; { start scan line = 6 ( normal ) }
port[$3d4]:=11;
port[$3d5]:=7; { stop scan line = 7 ( normal ) }
end;
begin {COLORTEST}
clrscr;
repeat
textmode(3);hirescolor(0);textcolor(6);
gotoxy(17,5);write('DEMO OF BORDER COLOR CHANGE IN TURBO PASCAL 2.0');
gotoxy(24,7);write('(applies to color-text-mode only)');
gotoxy(23,12);write('Input delay time (sec/1000) -- ');GetInteger(wait);
gotoxy(29,14);write('Press ');textcolor(30);write('<esc>');
textcolor(6);write(' to exit');
textcolor(0);textbackground(6);
gotoxy(28,16);write('╔════════════════════╗');
gotoxy(28,17);write('║ ║');
gotoxy(28,18);write('╚════════════════════╝');
textbackground(0);
ch:=chr(0);
CursorOff;
repeat
i:=0;
while i < 16 do
begin
if i=0 then begin textcolor(0);textbackground(7);end
else begin textbackground(0);textcolor(i);end;
str(i,num);
colormessage:=' '+num+' '+color[i]+' ';
offset:=length(colormessage);
tempoffset:=offset/2;
offset:=trunc(tempoffset);
gotoxy(30,17);write(' ');
gotoxy(39-offset,17);write(colormessage);
hirescolor(i);delay(wait);
if keypressed then read(kbd,ch);
if ch = #27 then i:=16;
i:=i+1;
end;
until ch = #27;
CursorOn;
hirescolor(0);textcolor(12);textbackground(0);
gotoxy(15,22);write('Repeat with different delay time (Y/N) ? ');
textcolor(10);read(kbd,ch);
if ch in ['Y','y'] then
begin
gotoxy(wherex,wherey);write('Yes');
end
else
begin
gotoxy(wherex,wherey);write('No');
end;
delay(750);
until not(ch in ['Y','y']);
end.